package name.as3.simpleUIComponents.core
{
import flash.display.Sprite;
import flash.interfaces.IDispose;
import flash.interfaces.ISafeGlobalOwner;
import flash.utils.SafeGlobalOwner;
import flash.utils.SafeGlobalProxy;

public class SimpleSprite extends Sprite implements IDispose, ISafeGlobalOwner
{
	private var m_global:SafeGlobalOwner;
	/**
	 *
	 */
	public function SimpleSprite()
	{
		super();
		m_global = new SafeGlobalOwner();
	}
//==================================================================================================
// public
//==================================================================================================
	public function dispose():void
	{
	}
	/**
	 * 获取SafeGlobal字典
	 */
	public function get sg():SafeGlobalProxy
	{
		return m_global.sg;
	}
	/**
	 * 返回safeGlobal次级对象
	 */
	public function sgs(obKey:* = null):*
	{
		return m_global.sgs(obKey);
	}
	/**
	 * 设置SafeGlobal字典
	 */
	public function set sg(value:SafeGlobalProxy):void
	{
		m_global.sg = value;
		onGlobalInited();
	}
	/**
	 * 当初始完成时
	 */
	public function onGlobalInited():void
	{
		
	}
	/**
	 * 设置尺寸
	 */
	public function setSize(nW:Number, nH:Number):void
	{
		super.width = nW;
		super.height = nH;
	}
	/**
	 * 设置位置
	 */
	public function setPosition(nX:Number, nY:Number):void
	{
		super.x = nX;
		super.y = nY;
	}
//==================================================================================================
// public final
//==================================================================================================
	override final public function set width(value:Number):void
	{
		this.setSize(value, this.height);
	}
	override final public function set height(value:Number):void
	{
		this.setSize(this.width, value);
	}
	/**
	 * 设置位置
	 */
	override final public function set x(value:Number):void
	{
		this.setPosition(value, this.y);
	}
	override final public function set y(value:Number):void
	{
		this.setPosition(this.x, value);
	}
}
}